package com.yf.common;
 
import lombok.Data;
 
import java.io.Serializable;
 
@Data
public class Resp<T> implements Serializable {
    private int code;
    private boolean success;
    private T data;
    private String msg;
 
    private Resp(int code, T data, String msg) {
        this.code = code;
        this.data = data;
        this.msg = msg;
        this.success = code == 200;
    }
 
    public static <T> Resp<T> ok(T data) {
        return new Resp<>(200, data, null);
    }
 
    public static <T> Resp<T> error(String msg) {
        return new Resp<>(500, null, msg);
    }
}